﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Talk.Common;
using OUtl;

namespace TalkServer
{
    partial class UserData
    {
        const string path = "User";
        const string sname = ".user";
        private string CurrentPath
        {
            get { return Environment.CurrentDirectory + "\\" + path; }
        }

        protected XMLDATAIO IOData = null;
        protected void initIOData()
        {
            if (IOData == null)
            {
                IOData = new XMLDATAIO(_className, CurrentPath, "123", typeof(SUSER));
            }
        }

        protected bool  Load(string name,out USER item,out List<int> lst)
       
        {
            if (!Directory.Exists(CurrentPath))
                Directory.CreateDirectory(CurrentPath);
            item = new USER();
            item.UserName = name;
            lst = null;
            if (File.Exists(CurrentPath + "\\" + name))
            {
                IOData.FileName = name + ".user";
                object obj = IOData.Load();
                if (obj != null && obj is SUSER)
                {
                    SUSER item2 = obj as SUSER;
                    if (item2.Groups != null)
                        lst = item2.Groups;
                    item.ID = item2.ID;
                    return true;
                }
            }
           
            return false;
        }



    }
}
